import './Timing.scss'
import { useState } from 'react'
import { Switch, InputNumber, Button } from 'antd'

const Timing = ({ data, ModalEvent, Off }) => {
    const [Open, setOpen] = useState(data.Open)
    const [Date, setDate] = useState(data.Date)
    const onSubmit = () => {
        ModalEvent.emit({ type: 'setTiming', data: { Open, Date } })
        Off()
    }
    return (
        <div className='Timing'>
            <div className='Options'>
                <div>是否启用</div>
                <Switch value={Open} onChange={setOpen} />
            </div>
            <div className='Options'>
                <div>刷新间隔</div>
                <InputNumber value={Date} onChange={setDate} />
            </div>
            <div className='Submit'>
                <Button type='primary' onClick={onSubmit}>保存设置</Button>
            </div>
        </div>
    );
};

export default Timing;